using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Server;
using System.IO;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();
builder.WebHost.ConfigureKestrel(options =>
{
    if (File.Exists(SocketPath))
    {
        File.Delete(SocketPath);
    }

    options.ListenUnixSocket(SocketPath);
});

var app = builder.Build();
app.MapGrpcService<GreeterService>();

app.Run();

public partial class Program
{
    private static readonly string SocketPath = Path.Combine(Path.GetTempPath(), "grpc-transporter.tmp");
}
